from 颜值检测_接口 import face_rg
import os


path = '.\\img'

image_list = os.listdir(path)
# print(len(image_list))

score_dict = {}

for image in image_list:
    try:
        name = image.split('.')[0]
        # print(name)
        image_path = path + '\\' + image
        # print(image_path)
        face_score = face_rg(image_path)
        score_dict[name] = face_score
    except Exception as e:
        print(f'正在检测：{name} | 检测失败')
    else:
        print(f'正在检测：{name} | 检测打分为：{str(face_score)}')


print('\n=========================================检测完成=========================================')
change_score = sorted(score_dict.items(), key=lambda x:x[1], reverse=True)      # 排序
# print(change_score)

# 数据输出
for a,b in enumerate(change_score):     # enumerate 枚举
    print(f'名中是:{change_score[a][0]} | 颜值名次：第{a+1}名 | 颜值分数：{change_score[a][1]}')














